<template>
  <div class="nurse-wrapper">
    <div class="sub-banner">
      <!-- <img :src="`${staticPath}/img_hulidaojia@2x.png`" alt=""> -->
      <van-swipe
        vertical
        class="huli-wrapper"
        :autoplay="3000"
        :show-indicators="false"
      >
        <van-swipe-item v-for="(item,index) in bannerList.huli.poster" :key="index">
          <img :src="item.picurl" alt="" srcset="">
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="service-panel">
      <h3 class="service-title">
        服务分类
      </h3>
      <div class="entry-list">
        <van-grid :column-num="5" :border="false">
          <van-grid-item :icon="item.picurl" :text="item.name" v-for="(item,index) in entryList" :key="index" @click="handleFilter(item)" />
        </van-grid>
      </div>
    </div>

    <div class="service-item">
      <van-cell is-link value="更多" style="padding-left: 15px;padding-right: 15px">
        <template #title>
          <div class="custom-title">
            <h3>服务项目</h3>/<span class="upper-letter">service items</span>
          </div>
        </template>
      </van-cell>
      <div class="items-wrapper" v-for="item in list" :key="item.id" @click="handleLink(item)">
        <div class="pic-wrapper">
          <van-swipe :autoplay="3000" v-if="item.picurl.length">
          <van-swipe-item v-for="(image, index) in item.picurl" :key="index" >
            <img :src="image" style="height: 200px"/>
          </van-swipe-item>
        </van-swipe>
        <img src="http://placehold.it/400x200?text=暂无图片" v-else alt="" style="height: 200px">
          <div class="thrunmb">
            <div class="left">
              <p class="title"><i></i>{{item.name}}</p>
              <div class="flex-desc">
                {{item.abstract}}
              </div>
            </div>
            <div class="right">
              <em>￥</em>{{item.price}}<em>元<i>/次</i></em>
            </div>
          </div>
        </div>
      </div>

      <div class="fixed-bottom">
        <van-pagination v-model="currentPage" :page-count="totalPage" :items-per-page="20" @change="turnPage" mode="simple" />
      </div>
    </div>
    <foot-tab></foot-tab>
  </div>
</template>

<script>
import { nurseItemServer,serverClassicOption } from '@/service/server'; 
import footTab from "@/components/footerTab/index";
import { mapGetters } from 'vuex';
export default {
  data(){
    return {
      currentPage: 1,
      pageSize: 20,
      totalPage: 0,
      staticPath: process.env.VUE_APP_STATIC_PATH,
      list: [],
      entryList: [],
      
    }
  },
  created(){
    let params = {
        pageNum: 1,
        expand: 'comment'
      }
      this.queryList(params)
      this.getServerList()
  },
  computed:{
    ...mapGetters(['bannerList'])
  },
  methods: {
    handleFilter(item){
      let params = {
        pageNum: 1,
        expand: 'comment',
        type: item.id
      }
      this.queryList(params)
    },
    handleLink(item){
      this.$router.push({
        path: `/huli/detail/${item.id}`
      })
    },
    turnPage(e){
      this.currentPage = e;
      let params = {
        pageNum: this.currentPage,
        expand: 'comment'
      }
      this.queryList(params)
    },
    async getServerList(){
      let result = await serverClassicOption();
      if(result.status == 200){
        this.entryList = result.data
      }else{
        this.$toast(result.message)        
      }
    },
    async queryList(params){
      let result = await nurseItemServer(params);
      if(result.status == 200){
        this.list = result.data.model
        this.pageSize = result.data._meta.totalCount
        this.currentPage = result.data._meta.pageCount
      }else{
        this.$toast(result.message)
      }
    }
  },
  components:{
    footTab
  }
}
</script>

<style lang="less">
@import '~@/assets/less/mixin.less';
.fixed-bottom{
  width: 100%;
  // position: fixed;
  bottom: 70px;
  padding: 10px;
  padding-bottom: 60px;
}
.sub-banner{
  width: 100%;
  height: 150px;
}
img{
  width: 100%;
}
.nurse-wrapper{
  background: #f5f5f5;

.service-panel{
  border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    position: relative;
    z-index: 1;
    margin-top: -10px;
    padding: 15px;
    background: #F8F8F8;
    .service-title{
      font-size: 16px;
      color: #000;
      padding: 0 10px;
    }
}
.service-item{
  margin-top: 10px;
  .custom-title{
    display: flex;
    justify-content: flex-start;
    font-size: 16px;
    color: #000;
  }
    .van-cell__value{
      font-size: 13px;
      flex: none;
    }
}
.van-grid-item__content,.van-cell{
    background: #F8F8F8;
    padding-left: 0;
    padding-right: 0;
  }
.items-wrapper{
  padding: 15px;
  .pic-wrapper{
    background: #F8F8F8;
    border-radius: 10px;
    box-shadow: 0px 2px 16px 0px rgba(204, 204, 204, 0.78);
  }
  
  .thrunmb{
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 14px 10px;
    .left{
      flex: 1;
      display: flex;
      justify-content: space-around;
      align-items: flex-start;
      flex-direction: column;
      .title{
        font-size: 16px;
        color: #000;
        margin-bottom: 8px;
      }
      .flex-desc{
        padding-top: 6px;
        height: 25px;
        line-height: 25px;
        .ellipsisLine(1)
      }
    }
    .right{
      color: #E02E2E;
      font-size: 18px;
      i{
        font-size: 13px;
      }
    }
  }
}
}
</style>